﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Inovout.Cloud.DataStore.Models;

namespace Inovout.Cloud.DataStore.Services
{
    public interface IPropertyService
    {
        /// <summary>
        /// 取得表的所有字段
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        IEnumerable<Property> GetProperties(Table table);

        /// <summary>
        /// 取得表的所有字段
        /// </summary>
        /// <param name="databaseName">数据库名</param>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        IEnumerable<Models.Property> GetProperties(String databaseName, String tableName);

        /// <summary>
        /// 取得字段的定义
        /// </summary>
        /// <param name="table"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        Property GetProperty(Table table, string propertyName);

        /// <summary>
        /// 创建一个字段
        /// </summary>
        /// <param name="property"></param>
        void CreateProperty(Property property);

        /// <summary>
        /// 批量创建字段
        /// </summary>
        /// <param name="properties"></param>
        void CreateProperties(List<Property> properties);

        /// <summary>
        /// 修改字段的类型
        /// </summary>
        /// <param name="table"></param>
        /// <param name="property"></param>
        /// <returns></returns>
        Property UpdateProperty(Table table, Property property);

        /// <summary>
        /// 批量更新表的字段
        /// </summary>
        /// <param name="table"></param>
        /// <param name="properties"></param>
        void UpdateProperties(Table table, List<Models.Property> properties);

        /// <summary>
        /// 保存字段
        /// </summary>
        /// <param name="table"></param>
        /// <param name="property"></param>
        void SaveProperty(Table table, Property property);

        /// <summary>
        /// 批量保存字段
        /// </summary>
        /// <param name="table"></param>
        /// <param name="properties"></param>
        void SaveProperties(Table table, List<Models.Property> properties);

        /// <summary>
        /// 根据主键删除
        /// </summary>
        /// <param name="id">主键</param>
        void DropProperty(object id);

        /// <summary>
        /// 删除字段
        /// </summary>
        /// <param name="table"></param>
        /// <param name="propertyName"></param>
        void DropProperty(Table table, string propertyName);

        /// <summary>
        /// 删除指定的字段定义
        /// </summary>
        /// <param name="table"></param>
        /// <param name="properties"></param>
        void DropProperties(Table table, List<Models.Property> properties);

        /// <summary>
        /// 删除指定的字段定义
        /// </summary>
        /// <param name="table"></param>
        /// <param name="propertyNames"></param>
        void DropProperties(Table table, List<string> propertyNames);

        /// <summary>
        /// 删除表的所有字段定义
        /// </summary>
        /// <param name="table"></param>
        void DropAllProperties(Table table);

        /// <summary>
        /// 删除用新的属性集合，然后用插入新的属性集合
        /// </summary>
        /// <param name="table"></param>
        /// <param name="properties">新的属性集合</param>
        void ReplaceAllProperties(Table table, List<Models.Property> properties);
    }
}
